<?php


namespace audit\server;


use app\common\model\School;
use app\traits\Api;

class HuBei extends Area
{

    function getAuditState($data)
    {
        if ($data['is_hk']==0){
            //中专学历(幼儿师范)
            if (in_array($data['education'],[1,2])){
                //报考类别是否是幼儿园
                if ($data['exam_type']!=1){
                    return Api::error('审核不通过：最高学习层次不和要求');
                }else{
                    //非在校生？
                    if ($data['is_school'] ==1){
                        //全日制
                        if ($data['is_full_time']==0){
                            return Api::error('审核不通过：非普通高等学校全日制在校生');
                        }else{
                            //中专需要毕业
                            if (date('Ymd')-$data['entrance']<$data['study_yeah']){
                                return Api::error('审核不通过：非毕业学年');
                            }else{
                                //学校是否在报考地区
                                $school= School::where('school_name',$data['school'])->field('province,city')->find();
                                $school_area = $school->province.' '.$school->city;
                                if ($school_area!=$data['exam_address']){
                                    //不是本市户籍的
                                    if ($data['census']!=$data['exam_address']){
                                         return Api::error('审核不通过：非本市考生');
                                    }
                                    return Api::error('审核不通过：非本市就读的非全日制考生');
                                }
                            }
                        }
                    }else{
                        //学校是否在报考地区
                        $school= School::where('school_name',$data['school'])->field('province,city')->find();
                        $school_area = $school->province.' '.$school->city;
                        if ($school_area!=$data['exam_address']){
                            //不是本市户籍的
                            if ($data['census']!=$data['exam_address']){
                                 return Api::error('审核不通过：非本市考生');
                            }
                            return Api::error('审核不通过：非本市就读的非全日制考生');
                        }
                    }
                }
            }


            //专科学历(高等师范)
            if (in_array($data['education'],[3,4])){
                //报考类别是否是幼儿园/小学/中职实习
                if (!in_array($data['exam_type'],[1,2,6])){
                    return Api::error('审核不通过：最高学习层次不和要求');
                }else{
                    //非在校生？
                    if ($data['is_school'] ==1){
                        //全日制
                        if ($data['is_full_time']==0){
                            return Api::error('审核不通过：非普通高等学校全日制在校生');
                        }else{
                            //专科需要毕业
                            if (date('Ymd')-$data['entrance']<$data['study_yeah']){
                                return Api::error('审核不通过：非毕业学年');
                            }else{
                                //学校是否在报考地区
                                $school= School::where('school_name',$data['school'])->field('province,city')->find();
                                $school_area = $school->province.' '.$school->city;
                                if ($school_area!=$data['exam_address']){
                                    //不是本市户籍的
                                    if ($data['census']!=$data['exam_address']){
                                         return Api::error('审核不通过：非本市考生');
                                    }
                                    return Api::error('审核不通过：非本市就读的非全日制考生');
                                }
                            }
                        }
                    }else{
                        //学校是否在报考地区
                        $school= School::where('school_name',$data['school'])->field('province,city')->find();
                        $school_area = $school->province.' '.$school->city;
                        if ($school_area!=$data['exam_address']){
                            //不是本市户籍的
                            if ($data['census']!=$data['exam_address']){
                                 return Api::error('审核不通过：非本市考生');
                            }
                            return Api::error('审核不通过：非本市就读的非全日制考生');
                        }
                    }
                }
            }


            //本科研究生学历
            if (in_array($data['education'],[5,6,7])){
                //非在校生？
                if ($data['is_school'] ==1){
                    //研究生
                    if (in_array($data['education'],[6,7])){
                        //学校是否在报考地区
                        $school= School::where('school_name',$data['school'])->field('province,city')->find();
                        $school_area = $school->province.' '.$school->city;
                        if ($school_area!=$data['exam_address']){
                            //不是本市户籍的
                            if ($data['census']!=$data['exam_address']){
                                 return Api::error('审核不通过：非本市考生');
                            }
                            return Api::error('审核不通过：非本市就读的非全日制考生');
                        }
                    }else{
                        //全日制
                        if ($data['is_full_time']==0){
                            return Api::error('审核不通过：非普通高等学校全日制在校生');
                        }else{
                            //中专需要毕业
                            if (date('Ymd')-$data['entrance']<3){
                                return Api::error('审核不通过：未到三年级或非毕业学年');
                            }else{
                                //学校是否在报考地区
                                $school= School::where('school_name',$data['school'])->field('province,city')->find();
                                $school_area = $school->province.' '.$school->city;
                                if ($school_area!=$data['exam_address']){
                                    //不是本市户籍的
                                    if ($data['census']!=$data['exam_address']){
                                         return Api::error('审核不通过：非本市考生');
                                    }
                                    return Api::error('审核不通过：非本市就读的非全日制考生');
                                }
                            }
                        }
                    }
                }else{
                    //学校是否在报考地区
                    $school= School::where('school_name',$data['school'])->field('province,city')->find();
                    $school_area = $school->province.' '.$school->city;
                    if ($school_area!=$data['exam_address']){
                        //不是本市户籍的
                        if ($data['census']!=$data['exam_address']){
                             return Api::error('审核不通过：非本市考生');
                        }
                        return Api::error('审核不通过：非本市就读的非全日制考生');
                    }
                }
            }
        }else{
            //学校是否在报考地区
            $school= School::where('school_name',$data['school'])->field('province,city')->find();
            $school_area = $school->province.' '.$school->city;
            if ($school_area!=$data['exam_address']){
                //不是本市户籍的
                if ($data['census']!=$data['exam_address']){
                    return Api::error('审核不通过：非本市考生');
                }
                return Api::error('审核不通过：非本市就读的非全日制考生');
            }
        }
        return Api::success('恭喜！您的信息成功通过验证');
    }
}